#ifndef BBH_PATTERN_H_
#define BBH_PATTERN_H_
#ifdef __cplusplus
extern "C"
{
#endif

#include "bbh_include.h"

#include "bbh_linkitem.h"

struct pattern_item_s
{
    char                * s;            // bbh_pattern_s.pattern, item
    size_t              len;
    char                spec[2];        // 特征字
    bbh_linkitem_t      link_item;
};

struct bbh_pattern_s
{
    char                * pattern;
    bbh_linkitem_t      root;
};


// 返回写入的字节长度
typedef int (*pattern_output_callback)(void*data, char spec[2], const char*buffer, size_t len);

int  bbh_pattern_create(void**pptr);
int  bbh_pattern_output(void*_, pattern_output_callback cb, void*cb_data);
int  bbh_pattern_parse(void*_, const char*format);
/* 检验格式 */
int  bbh_pattern_verify(void*_);
void bbh_pattern_clear(void*_);
void bbh_pattern_free(void*_);

#ifdef __cplusplus
}
#endif
#endif